<?xml version="1.0" encoding="UTF-8"?>
<ui:composition xmlns="http://www.w3.org/1999/xhtml"
   xmlns:ui="http://xmlns.jcp.org/jsf/facelets"
   xmlns:f="http://xmlns.jcp.org/jsf/core"
   xmlns:h="http://xmlns.jcp.org/jsf/html"
   xmlns:p="http://primefaces.org/ui"   
   xmlns:c="http://xmlns.jcp.org/jsp/jstl/core"
   template="/WEB-INF/templates/default.xhtml">
   
   	<f:metadata>	   	
	   	<f:viewParam name="firstResult" value="#{bulletinList.firstResult}"></f:viewParam>
	   	<f:viewParam name="maxResults" value="#{bulletinList.maxResults}"></f:viewParam>
	   	<f:event listener="#{qualificationClassList.setMaxResults(99999)}" type="preRenderView"></f:event>
	   	<f:viewParam name="moduleName" value="公告管理"></f:viewParam>
	   	<f:viewParam name="projectName" value="#{bulletinList.projectName}"></f:viewParam>
		<f:viewParam name="region" value="#{bulletinList.region}"></f:viewParam>
	   	<f:viewParam name="buyerName" value="#{bulletinList.buyerName}"></f:viewParam>
		<f:viewParam name="qClassId" value="#{qualificationConditionBean.qualificationClassId}"></f:viewParam>
		<f:viewParam name="sectorId" value="#{qualificationConditionBean.sectorId}"></f:viewParam>
		<f:viewParam name="childSectorSno" value="#{qualificationConditionBean.childSectorSno}"></f:viewParam>
		<f:viewParam name="certLevel" value="#{qualificationConditionBean.certLevel}"></f:viewParam>
   	</f:metadata>
   
   	<ui:define name="content">
   
		<h:form id="searchForm">
			<div style="height:120px;margin-left:10px" >
				<p:outputLabel value="项目名称："></p:outputLabel>				
				<p:inputText value="#{bulletinList.projectName}"></p:inputText>
				#{'    '}
				<p:outputLabel value="采购人："></p:outputLabel>				
				<p:inputText value="#{bulletinList.buyerName}"></p:inputText>
				#{'    '}
				<p:outputLabel value="所属县区：" style="display: inline-block;margin-top: 5px;"></p:outputLabel>
				<p:selectOneMenu id="region"
								 value="#{bulletinList.region}">
					<f:selectItem itemLabel="请选择" itemValue="#{null}"  />
					<f:selectItems value="#{codeDicUtils.getCodeDicList('所在地区')}" var="_codeDic" itemValue="#{_codeDic.codeValue}"
								   itemLabel="#{_codeDic.codeName}" />
				</p:selectOneMenu>
				<br/>
				<div style="margin-top:10px;">
					<p:outputLabel value="资质范围：" style="display:inline-bloack;margin-top:10px;"></p:outputLabel>
					<p:outputLabel>
						<p:selectOneMenu
							value="#{qualificationConditionBean.qualificationClassId}"
						>
							<f:selectItem
								itemLabel="--请选择--"
								itemValue="#{null}"
							/>
							<f:selectItems
								value="#{qualificationClassList.resultList}"
								var="_class"
								itemLabel="#{_class.name}"
								itemValue="#{_class.id}"
							>
							</f:selectItems>
							<f:ajax render="sectorId certLevel"></f:ajax>
						</p:selectOneMenu>#{' '}
						<p:selectOneMenu
							id="sectorId"
							widgetVar="sectorId"
							value="#{qualificationConditionBean.sectorId}"
						>
							<f:selectItem
								itemLabel="--请选择--"
								itemValue="#{null}"
							/>
							<f:selectItems
								value="#{qualificationConditionBean.sectors}"
								var="_sector"
								itemLabel="#{_sector.sectorName}"
								itemValue="#{_sector.id}"
							></f:selectItems>
							<f:ajax event="change" listener="#{qualificationConditionBean.initChildSectors()}" render="childSectorId"></f:ajax>
						</p:selectOneMenu>
						
						<p:selectOneMenu
							id="childSectorId"
							widgetVar="childSectorId"
							value="#{qualificationConditionBean.childSectorSno}"
						>
							<f:selectItem
								itemLabel="--请选择--"
								itemValue="#{null}"
							/>
							<f:selectItems
								value="#{qualificationConditionBean.childSectors}"
								var="_childsector"
								itemLabel="#{_childsector.sectorName}"
								itemValue="#{_childsector.sno}"
							></f:selectItems>
						</p:selectOneMenu>
					</p:outputLabel>
					<ui:remove>
						<p:outputLabel value="资质等级："></p:outputLabel>
						<p:selectOneMenu
							id="certLevel"
							value="#{qualificationConditionBean.certLevel}"
						>
							<f:selectItem
								itemLabel="--请选择--"
								itemValue="#{null}"
							/>

							<f:selectItems
								value="#{qualificationConditionBean.qualificationLevels}"
								var="_level"
								itemLabel="#{_level.name}"
								itemValue="#{_level.value}"
							></f:selectItems>
						</p:selectOneMenu>
					</ui:remove>

				</div>
						
				<div class="actionButtons" style="margin-top:10px;">
					<p:commandButton value="查询" ajax="false"  action="BulletinList.xhtml?faces-redirect=true&amp;includeViewParams=true&amp;firstResult=0" styleClass="blue-int"></p:commandButton>
					#{'    '}
					<p:button value="重置" outcome="BulletinList.xhtml"></p:button>
				</div>				
				<div class="clearbt"></div>
			</div>
			<p:panel id="searchResult" header="公告管理">
				<p:dataTable value="#{bulletinList.resultList}" var="_bulletin">
					
					<p:column>
						<f:facet name="header">项目名称</f:facet>
						#{_bulletin.projectName}
					</p:column>
					
					<p:column width="60">
						<f:facet name="header">选取方式</f:facet>
						#{_bulletin.wayOfChoose.typeName}
					</p:column>
					
					<p:column>
						<f:facet name="header">采购人</f:facet>
						#{_bulletin.buyer.cnname}
					</p:column>
					<p:column>
						<f:facet name="header">所属县区</f:facet>
						#{codeDicUtils.getCodeDicValueKeyMap('所在地区')[_bulletin.buyer.region]}
					</p:column>
					<p:column width="130">
						<f:facet name="header">报名截止时间</f:facet>
						<h:outputText value="#{_bulletin.endingApplyTime}"  >
							<f:convertDateTime pattern="yyyy-MM-dd HH:mm"/>
						</h:outputText>
					</p:column>
					
					<p:column width="80">
						<f:facet name="header">交易状态</f:facet>
						#{_bulletin.tradeStatus.typeName}
					</p:column>
					
					<p:column width="60">
						<f:facet name="header">状态</f:facet>
						
						<ui:include src="/WEB-INF/templates/outputBoolean.xhtml">
							<ui:param name="booleanValue" value="#{_bulletin.auditResult}" />
						</ui:include>
					</p:column>
					
					<p:column styleClass="actionColumn" style="width:200px">
						<f:facet name="header">操作</f:facet>
						<p:button outcome="BulletinView.xhtml" value="查看" target="_blank">
							<f:param name="bulletinId" value="#{_bulletin.id}"></f:param>
						</p:button>
						
						<p:button outcome="BulletinViewAppliedSupplier.xhtml" rendered="#{_bulletin.auditResult}"  target="_blank" value="报名详情">
							<f:param name="bulletinId" value="#{_bulletin.id}"></f:param>
						</p:button>
						<p:button id="rechoose" outcome="BulletinRechoose.xhtml" rendered="#{_bulletin.tradeStatus eq 'Agreed' &amp;&amp; _bulletin.wayOfChoose eq 'Random'}"  target="_blank" value="重新选取">
							<f:param name="bulletinId" value="#{_bulletin.id}"></f:param>
						</p:button>
						<p:button id="cancel" outcome="BulletinCancelCurrent.xhtml" rendered="#{_bulletin.tradeStatus eq 'Agreed' &amp;&amp; (_bulletin.wayOfChoose eq 'Best' || _bulletin.wayOfChoose eq 'Average' || _bulletin.wayOfChoose eq 'Price')}"  target="_blank" value="公告作废">
							<f:param name="bulletinId" value="#{_bulletin.id}"></f:param>
						</p:button>
						<ui:remove>
							<p:button outcome="SelfDefinedSms.xhtml" rendered="#{_bulletin.auditResult}" value="自定义短信" >
								<f:param name="bulletinId" value="#{_bulletin.id}"></f:param>
							</p:button>
						</ui:remove>
						<p:tooltip value="针对已经成交的随机选取公告，此功能可以进行重选选取！" for="rechoose"></p:tooltip>
						<p:tooltip value="针对已经成交的择优选取、均价选取、竞价选取公告，此功能可以废掉上次中选的中介，自动顺延，使下一名中介中选！" for="cancel"></p:tooltip>
					</p:column>
				</p:dataTable>
			</p:panel>
			
			<ui:include src="/WEB-INF/templates/manage/pagination.xhtml">
				<ui:param name="entityList" value="#{bulletinList}" />
			</ui:include>
			
		</h:form>
      
   	</ui:define>
</ui:composition>
